@extends("layout.app")

@section("content")

    <div class="form-inline">

        <div class="form-group has-success">
            <input class="form-control" id="begin_time" placeholder="开始时间" value="<?php echo $begin_time?>"/>
        </div>
        <div class="form-group has-success">
            <input class="form-control" id="end_time" placeholder="结束时间" value="<?php echo $end_time?>"/>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-default" onclick="jQuery('#rowed3').setGridParam({postData: postData()}).trigger('reloadGrid')"><i class="fa fa-search"></i> 查询</button>
        </div>
    </div>
    <div class="separator"></div>
    <div class="box-body">

        <table id="rowed3"></table>
        <div id="prowed3"></div>

    </div>

<script>

$(document).ready(function() {

	var data = {
        url :"/agent/order?is_agent={{$is_agent}}&user_id={{$user_id}}&agent_id1={{$agent_id1}}&agent_id2={{$agent_id2}}&agent_id3={{$agent_id3}}",
        postData: postData(),
        colNames: ["完成时间" , "订单号" , "用户ID" , "渠道" , "充值" , "1级代理" ,  "2级代理" , "3级代理" , ""],
        colModel: [
            {
                name: 'time',
                formatter:'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                searchoptions: {
                    sopt: ['lt', 'le', 'gt', 'ge'],
                    dataInit : function (elem) {
                        $(elem).datepicker({
                            dateFormat: 'yy-mm-dd',
                            monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                            dayNamesMin: ['日','一','二','三','四','五','六'] });
                    }
                }
            }, {
                name: "order_id",
                key: true
            }, {
                name: "user_id",
                sortable: false
            }, {
                name: "spid",
                stype: "select",
                searchoptions: {
                    sopt: ["eq" , "ne"],
                    value: "{{$pfs}}"
                }
            }, {
                name: "rmb",
                formatter: function(cellvalue) {
                	cellvalue = parseFloat(cellvalue) / 100.0;
                    return "¥" + cellvalue;
                }
            }, {
                name: "agent_id1",
                cellattr: function addCellAttr(rowId, val, rawObject) {
                    if (rawObject["agent_id1"] && !rawObject["agent_id2"] && !rawObject["agent_id3"]) {
                    	return "style='class:#444;background:#fbf8ee'";
                    }
 				}
            }, {
                name: "agent_id2",
                cellattr: function addCellAttr(rowId, val, rawObject) {
                    if (rawObject["agent_id2"] && !rawObject["agent_id3"]) {
                    	return "style='class:#444;background:#fbf8ee'";
                    }
 				}
            }, {
                name: "agent_id3",
                cellattr: function addCellAttr(rowId, val, rawObject) {
                    if (rawObject["agent_id3"]) {
                    	return "style='class:#444;background:#fbf8ee'";
                    }
 				}
            }, {
           		name: "sum",
           		hidden: true
            }],
        caption: '<i class="fa fa-list"></i> {{$label2}}',
        sortname: "time",
        sortorder: "desc",
        autowidth: false,
        editurl: "",
        gridComplete: function() {

            var sum = 0;
            if (($(this).getCol("sum").length)){

                sum = $(this).getCol("sum")[0];
            }

            $(this).footerData("set", {"rmb": sum});
        }
    };

	jqGrid(data);

    $(".form-control").datepicker({
        dateFormat: 'yy-mm-dd',
        monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
        dayNamesMin: ['日','一','二','三','四','五','六'] });
});

function postData() {

    return {
        begin_time: $("#begin_time").val(),
        end_time: $("#end_time").val()
    }
}

</script>
@endsection